package org.jadestudio.dsdown.service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.jadestudio.dsdown.dao.ManageLoginDao;
import org.jadestudio.dsdown.entity.ManageAdminLogin;
import org.springframework.stereotype.Component;

@Component
public class ManageLoginService {
	@Resource
	ManageLoginDao manageLoginDao;
	/**
	 * 用户登录
	 * @param manageAdminLogin
	 * @param request
	 * @return
	 */
	public int  userLogin(ManageAdminLogin manageAdminLogin,HttpServletRequest request){
		try {
			int manageLoginFlag = manageLoginDao.userLogin(manageAdminLogin,request);
			return manageLoginFlag;
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
	}
	/**
	 * 登录SESSION自检
	 * @param request
	 * @return
	 */
	public int userSessionRecheck(HttpServletRequest request){
		try {
			int manageLoginFlag = manageLoginDao.sessionRecheck(request);
			return manageLoginFlag;
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
	}
	/**
	 * 用户登出
	 * @param request
	 * @return
	 */
	public int userLoginOut(HttpServletRequest request){
		try {
			manageLoginDao.userLoginOut(request);
			return 1;
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
		
	}
}
